/*
 * =====================================================================================
 *
 *       Filename:  config.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2020年06月10日 13时29分17秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */

#ifndef _MULTILINK_CONFIG_H_
#define _MULTILINK_CONFIG_H_
#include "list.h"
#include <stdint.h>

#define TRACK_STATUS_UP 1
#define TRACK_STATUS_DOWN 0
#define INTERFACE_LINK_UP 1
#define INTERFACE_LINK_DOWN 0
#define HSION_MLINK_DEFAULT_UP       3
#define HSION_MLINK_DEFAULT_DOWN     3
#define HSION_MLINK_DEFAULT_COUNT    1
#define HSION_MLINK_DEFAULT_WEIGHT   1
#define HSION_MLINK_DEFAULT_TIMEOUT  3
#define HSION_MLINK_DEFAULT_INTERVAL 1

struct track_ip {
    uint32_t ip;
    struct list_head list;
};

struct mLink_interface {    
    char uci_sec_name[32];
    /* 配置 */
    char net[32];
    uint8_t up;
    uint8_t down;
    uint8_t count;
    uint8_t weight;
    uint8_t metric; /* 从network/interface中读取 */
    uint8_t timeout;
    uint8_t interval;
    struct list_head list;
    struct list_head head_track_ip;

    /* track结果 */
    uint8_t track_status; /* TRACK_STATUS_UP/TRACK_STATUS_DOWN */
};

int hsion_mLink_config_init(struct list_head *head, int *enabled);
int util_uci_set(const char *package, const char *section, const char *option, char *value);
int util_uci_get(const char *package, const char *section, const char *option, char *value, int len);

#endif

